<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateUserTable extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
        // create the table
        $table = $this->table('user_logins');

        // 添加其他字段
        $table->addColumn('user_id', 'string')
            ->addColumn('phone_number', 'string', ['limit' => 11])
            ->addColumn('nickname', 'string', ['limit' => 255])
            ->addColumn('created_at', 'datetime')
            ->addColumn('updated_at', 'datetime')
            ->addColumn('avatar', 'string', ['limit' => 255])
            ->addColumn('user_type', 'string', ['limit' => 255])
            ->addColumn('balance', 'decimal', ['precision' => 10, 'scale' => 2])
            ->addColumn('is_available', 'boolean')
            ->addColumn('login_password', 'string', ['limit' => 255])
            ->addColumn('trade_password', 'string', ['limit' => 255])
            ->addColumn('auth_password', 'string', ['limit' => 255]);

        // 保存迁移
        $table->save();
    }
}
